/*
 ============================================================================
 Name        : Keyboard.java
 Author      : Dallas Rosson, Joshua Warner, Tyson Lewis, Ken Norton
 Team        : Bitwise Guys
 ============================================================================
 */

package backend;

/**
 * KeyBoard.java
 * 
 * Simulates the KeyBoard for hardware.
 * 
 * @author BitWiseGuys Dallas Rosson, Joshua Warner, Tyson Lewis, Ken Norton
 * @version 1.0, 5/29/2012
 */
public class KeyBoard extends IO {
	private Cpu my_cpu;
	
	/**
	 * creates a new KeyBoard class that uses the provided queue 
	 * to represent requests to the keyboard.
	 * @param the_queue of processes waiting for a response from the keyboard.
	 */
	public KeyBoard(IO.IOType io_type, Cpu the_cpu) {
		super(io_type, the_cpu);
		my_cpu = the_cpu;
	}
	
	public void keyPressed(){
		IO.IOType my_io_type = IO.IOType.KEYBOARD;
		
		if (my_cpu.getInterruptState() != Cpu.Interrupt.DISABLED){
			my_cpu.setInterruptState(Cpu.Interrupt.DISABLED);
			
			my_cpu.setIo_type(my_io_type);
			my_cpu.setInterruptHandle(Cpu.Interrupt_Handle.IO_INT_HANDLE);
		}
	}
}
